Consider the following:
Code:
#include <stdio.h>
int main(void)
{
int i = 3;
switch (i){
default:
i = -1;
break;
case 1:
case 2:
case 3:
i = 5;
break;
}
printf ("i = %i.\n", i);
return 0;
}
Output is:
i = 5.
Is this a definition of the standard, or is this compiler specific (ie, gcc). This code example is one that I tried and it works as if the default was at the end, but I would think it would match the default FIRST and never test against 1,2,3.
The code that coRnfused me was from the Linux kernel in the file kernel/posix-cpu-timers.c.
Thanks in advance for your answers.
Andy